import { getLodop } from "@/utils/LodopFuncs"
export async function print(data) {
  const LODOP = getLodop();
  if (!LODOP) return;
  LODOP.PRINT_INITA("0mm", "0mm", "210mm", "148mm", "裕酷科技_ERP系统_拣货单打印");
  LODOP.SET_LICENSES("", "EE0887D00FCC7D29375A695F728489A6", "C94CEE276DB2187AE6B65D56B3FC2848", "");
  for (let i = 0; i < data.length; i++) {
    let { chooseNumber, commodityNum, regionName, chooseDetailsVoList } = data[i];
    let style = `<style>
  table {border-collapse: collapse;width: 700px !important;}
  td,th {text-align: center;border-bottom: 1px solid #000;padding: 1px;padding:10px 0 5px;}
  td{font-size:14px}
  </style><body>`;
    let tableStr = "<table><thead><tr><th>序号</th><th>货位号</th><th>商品名称</th><th>规格</th><th>单位</th><th>数量</th></tr></thead><tbody>" +
      chooseDetailsVoList.map((row, index) => {
        return `<tr>
              <td>${index + 1}</td>
              <td style="font-weight:bold">${row.positionName}</td>
              <td>${row.commodityName}</td>
              <td>${row.standard}</td>
              <td>${row.unitName}</td>
              <td style="font-weight:bold">${row.procureNumber + 1}</td>
            </tr>`
      }).join("") + "</tbody></table>" + "</body>"
    LODOP.NEWPAGEA();
    LODOP.SET_PRINT_PAGESIZE(2, 0, 0, "A5");
    LODOP.ADD_PRINT_TABLE(112, 42, 700, "700px", style + tableStr);
    LODOP.ADD_PRINT_HTM(25, "80.869%", 146, 28, `<p style="font-weight:bold;font-size:16px"><span tdata='pageNO'>第##页</span> <span tdata='pageCount'>共##页</span></p>`);
    LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
    LODOP.SET_PRINT_STYLEA(0, "Horient", 1);
    LODOP.ADD_PRINT_HTM(25, 40, 121, 34, `<p style="font-weight:bold;font-size:16px">区域:${regionName}</p>`);
    LODOP.SET_PRINT_STYLEA(0, "ItemType", 0);
    LODOP.ADD_PRINT_HTM(25, "45.00%", 113, 35, `<p style="font-weight:bold;font-size:16px">品规数:${commodityNum}</p>`);
    LODOP.SET_PRINT_STYLEA(0, "ItemType", 0);
    LODOP.SET_PRINT_STYLEA(0, "Horient", 4);
    LODOP.ADD_PRINT_HTM(80, 42, 250, 40, `<p style="font-weight:bold;font-size:18px">单号:${chooseNumber}</p>`);
    LODOP.SET_PRINT_STYLEA(0, "ItemType", 0);
    // LODOP.SET_PRINT_MODE("PRINT_PAGE_PERCENT","50%");
  }
  LODOP.PRINT_DESIGN();


}